package cn.aloxc.tianya.reader;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

import android.app.ListActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import cn.aloxc.custom.MyAdapter;

public class Activity_test_list_my extends ListActivity{
	MyAdapter adapter = null;
	ArrayList<Map<String, String>> datas = null;
	public void onCreate(Bundle savedInstanceState){
		super.onCreate(savedInstanceState);
        Bundle data = this.getIntent().getExtras();
        setTitle(data.getString("testItem"));
        setData();

        adapter = new MyAdapter(this,R.layout.activity_test_list_myadapter,datas);
        this.setListAdapter(adapter);
        this.getListView().setOnItemClickListener(new OnItemClickListener(){
			public void onItemClick(AdapterView<?> parent, View v, int pos,
					long id) {
//				Map<String, String> item = (Map<String, String>)parent.getItemAtPosition(pos);
				Log.i("TAG","click it");
			}});
	}
	private void setData() {
		datas = new ArrayList<Map<String,String>>();
		Map<String, String> item;
		for (int i = 0; i <= 50; i++) {
			item = new HashMap<String, String>();
			item.put("name", String.valueOf(i).length()==1?"张三0"+i:"张三"+i);
			item.put("sex", i%2==0?"男":"女");
			item.put("mobile", String.valueOf(i).length()==1?"1303491000"+i:"130349100"+i);
			item.put("img", String.valueOf(R.drawable.phone));
			datas.add(item);
		}
	}
}
